Let’s create an experimental_data(temp, conc) function that simulates the yield of a chemical reaction based on temperature, concentration A, concentration B and concentration C.
import numpy as npimport pandas as pdimport plotly.graph_objects as goimport plotly.io as piopio.renderers.default ="notebook"def experimental_data(temp, cA, cB, cC):""" This function simulates experimental data based on temperature and concentrations. The function is not based on any real experimental data and is purely for demonstration purposes. """ out =.2*temp +.5*temp*cA + (cA)/3+ (1- cB)**2/2+ (3- cC)/1.5+ np.random.normal(0, 0.2, len(temp))return outdef generate_data(N=100): temp = np.random.uniform(0, 100, N) cA = np.random.uniform(0, 1, N) cB = np.random.uniform(0, 1, N) cC = np.random.uniform(0, 1, N) exp_response = experimental_data(temp, cA, cB, cC)# Create a DataFrame with the generated data df = pd.DataFrame({'temp': temp, 'cA': cA, 'cB': cB, 'cC': cC, 'response': exp_response})return dfdf = generate_data(50)df.to_csv('dataML.csv', index=False)df.head()
temp
cA
cB
cC
response
0
65.150929
0.856934
0.143145
0.202648
43.365583
1
70.857440
0.611890
0.588674
0.089296
37.581891
2
84.400019
0.827279
0.546844
0.081419
53.979769
3
32.449034
0.888718
0.713346
0.640800
23.005230
4
64.010182
0.757054
0.611216
0.881803
38.662838
Now, we will use the OPTIMEO package to analyse the data.